﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 密封类
{
    public class A
    {
        public virtual void a()    //只有被重写的方法才能被密封
        {
            Console.WriteLine("haha");
        }
 
    }
    class B:A
    {
        public sealed override void a()   //用sealed关键字对a（）方法进行密封，让该方法只能被继承，不能再被重写
        {
            base.a();
            Console.WriteLine("hehe");
        }
    }
    class C:B
    {

    }
    class Program
    {
        static void Main(string[] args)
        {
            A a = new A();
            B b = new B();
            C c = new C();
            a.a();
            b.a();
            c.a();
                

   
        }
    }
}
